//引用 可达
//@ts-check
const {log} = console
let obj = { name: "xiaoming" }

let ali = obj  //{name: "xiaoming"}又多了一次引用

obj = null //{name: "xiaoming"} 可达吗？ 可达



//循环引用对象

function fn() {
    const obj1 = {}
    const obj2 = {}
    obj1.name = obj2
    obj2.name = obj1
}


var a = []
for (var i = 0; i < 10; i++) {

    a[i] = function () {
        console.log(i)
    }
}
console.log(a)

a[6]()

var tmp = 123

if (true) {
    console.log(tmp)
    let temp
}


var arr = [12, 34, 32, 89, 4]

console.log(Math.min(...arr))

const o1= {
    name: "Jack",
    age: 18
}

const o2 = o1
log(o2)
o2.name="Ella"
log(o2)
log(o1)

// let o2 = JSON.parse(JSON.stringify(o1))
function deepCopy(s) {
    const d = {}
    for (let k in s) {
        if (typeof s[k] == 'object') {
            d[k] = deepCopy(s[k])
        } else {
            d[k] = s[k]
        }
    }
    return d
}


var i, str = ''
for(i=0; i<1000; i++){
    str+=i
}

for(let i=0; i<1000; i++){
    let str = ''
    str + = i
}